{extend name="base" /}
<!-- page specific plugin styles -->
{block name="inline-styles"}
{/block}
<!-- PAGE CONTENT BEGINS -->
{block name="content"}
<div class="page js_show">
    <div class="page__bd">
        <form class="weui-cells" id="ajaxForm">
            <div class="weui-cell">
                <div class="weui-cell__bd">姓名</div>
                <div class="weui-cell__ft" id="name"></div>
            </div>

            <div class="weui-cell">
                <div class="weui-cell__bd">微信号</div>
                <div class="weui-cell__ft" id="weixin"></div>
            </div>

            <div class="weui-cell">
                <div class="weui-cell__bd">级别</div>
                <div class="weui-cell__ft" id="grade"></div>
            </div>

            <div class="weui-cell">
                <div class="weui-cell__bd">手机号</div>
                <div class="weui-cell__ft" id="tel"></div>
            </div>

            <div class="weui-cell">
                <div class="weui-cell__bd">推荐人</div>
                <div class="weui-cell__ft" id="fname"></div>
            </div>

            <a class="weui-cell weui-cell_access" href="{:url('Index/address_start')}">
                <div class="weui-cell__bd">发货地址</div>
                <div class="weui-cell__ft"></div>
            </a>

            <a class="weui-cell weui-cell_access" href="{:url('Index/bind_wechat')}">
                <div class="weui-cell__bd">绑定微信</div>
                <div class="weui-cell__ft"></div>
            </a>

            <a class="weui-cell weui-cell_access" href="{:url('Index/password')}">
                <div class="weui-cell__bd">修改密码</div>
                <div class="weui-cell__ft"></div>
            </a>

        </form>

        <div class="weui-btn-area">
            <a class="weui-btn weui-btn_warn" href="javascript:void(0)" id="showToast">退出登陆</a>
        </div>
    
    </div>
    <div class="page__ft">
        <div class="weui-footer weui-footer_fixed-bottom">
            <p class="weui-footer__links">
                <a href="javascript:void(0);" class="weui-footer__link">米粒生活</a>
            </p>
            <p class="weui-footer__text">Copyright © 2008-2018 mlilife.com</p>
        </div>
    </div>
</div>
{/block}
<!-- PAGE CONTENT ENDS -->
<!-- inline scripts related to this page -->
{block name="related-scripts"}
<script type="text/javascript">
    $.ajax({
        url: '/api/v1/member/index',
        type: 'GET',
        dataType: 'json',
    })
    .done(function(json) {
        console.log("success");
        initPageHTML("ajaxForm",json.data);
    })
    .fail(function() {
        console.log("error");
    })
    .always(function() {
        console.log("complete");
    });
    

    // 退出登录
    $("#showToast").click(function(event) {
        /* Act on the event */
        var options={
            url:"/api/v1/member/outlogin",
            type:"GET",
            dataType:"json",
            success: function(json){

                if(json.returnCode==1){
                    $.toast("退出成功", function() {
                        window.location.href = "{:url('Index/login')}";
                    });
                }else{
                    $.toptip(json.returnMsg, 'error');
                }
            }
        };
        $("#ajaxForm").ajaxSubmit(options)
    });

//重置浏览器回退链接
browserBack("home.html");
</script>
{/block}